<template>
  <el-dialog
    v-model="dialogVisible"
    title="查询货位"
    width="900px"
    @close="closeDialog"
  >
    <el-form class="aceauForm" label-width="120px" :model="state.form">
      <el-row :gutter="12">
        <el-col :span="12">
          <el-form-item label="货位编码">
            <el-input v-model="state.form.goodsShelvesCode" placeholder="" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="货位名称" required>
            <el-input v-model="state.form.goodsShelvesName" placeholder="" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="货位类型" required>
            <el-select
              v-model="state.form.goodsShelvesType"
              placeholder="类型"
              style="width: 100%"
            >
              <el-option
                v-for="type in types"
                :key="type.goodsShelvesType"
                :label="type.name"
                :value="type.goodsShelvesType"
              />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="dialogVisible = false">取消</el-button>
        <el-button type="primary" @click="query">查询</el-button>
      </span>
    </template>
  </el-dialog>
  <invSelect ref="invSelectRef" @selected-callback="invSelectCallback" />
</template>

<script setup>
  import { localStorageConfig } from '@/config/localstorage.config'

  const pkCorp = localStorage.getItem(localStorageConfig.__pkCorp)
  const dialogVisible = ref(false)

  const state = reactive({
    form: {
      pkCorp: pkCorp,
    },
  })

  const types = ref([
    { goodsShelvesType: 0, name: '货架货位' },
    { goodsShelvesType: 1, name: '地面货位' },
  ])

  const openDialog = () => (dialogVisible.value = true)

  const query = () => {
    dialogVisible.value = false
    _emit('success-callback', state.form)
  }

  defineExpose({ openDialog })
  const _emit = defineEmits(['success-callback'])
</script>
